<?php
//  This file is part of EkkinCMS.
//
//  EkkinCMS is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  EkkinCMS is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with EkkinCMS.  If not, see <http://www.gnu.org/licenses/>.

include_once("ext_lib/simple_html_dom.php");

function execute_lightbox($site_content){

    $html = str_get_html($site_content);

    // Configure images for lightbox integration. when img id startswith lightbox, the values will be set in a hyperlink to trigger lightbox.
    foreach($html->find("img") as $element){
        if (str_startswith($element->id, "lightbox")){
            $url = $element->src;
            $title = $element->title;
            $align = $element->align;
            $style = $element->style;
            $rel = $element->id;
            $width = $element->width;
            $height = $element->height;
            $thumb = $url;//str_replace("user_files/images", "user_files/images/thumbs", $url);
            $element->outertext = "<a href=\"$url\" title=\"$title\" rel=\"$rel\"><img width=\"$width\" height=\"$height\" style=\"$style\" align=\"$align\" class=\"thumb\" src=\"$thumb\"/></a>";
        }
    }

    return $html->save();
}

?>


